<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<title>JFinal--Controller 传参</title>
<script language="javascript" type="text/javascript" src="<%=basePath %>assets/js/datepicker/WdatePicker.js"></script>
<script type="text/javascript">
function submitForm(){
	var age=$("#age").val();
	if(isNaN(age)){
		alert("年龄请输入数字");
	}else{
		$("#form1").submit();
	}
}
</script>
<style type="text/css">
fieldset{
margin-bottom: 20px;
}
</style>
<jsp:include page="../header.jsp"></jsp:include>
	<div class="container" style="background: #FFF;">
		<div class="page-header">
		  <h1>JFinal Controller 传参</h1>
		</div>
		<div class="row mainRow" >
	<div class="col-lg-6 col-md-6 col-sm-6">
		<fieldset>
			<legend>URL 超链接 浏览器通过URL链接地址传参</legend>
			一个参数：<br> <a href="/param/urloneparam?param=1" target="_blank">/param/urloneparam?param=1</a><br>
			<a href="/param/urloneparam/1" target="_blank">/param/urloneparam/1</a>
			<hr />
			多个参数：<br> <a href="/param/urlmoreparam?param1=1&param2=2"
				target="_blank">/param/urlmoreparam?param1=1 & param2=2</a><br>
			<a href="/param/urlmoreparam/1-2" target="_blank">/param/urlmoreparam/1-2</a>
		</fieldset>

		<fieldset>
			<legend>Form表单 Post提交</legend>
			<form action="/param/form" class="form-horizontal" role="form"  method="post" id="form1" target="_blank">
			<div class="form-group">
			    <label  class="col-sm-2 control-label">姓名</label>
			    <div class="col-sm-10">
			      <input type="text"  value="小木学堂" class="form-control" maxlength="40" name="name"   placeholder="填写姓名">
			    </div>
			  </div>
			<div class="form-group">
			    <label  class="col-sm-2 control-label">年龄</label>
			    <div class="col-sm-10">
			      <input type="text" class="form-control" maxlength="2" value="25" name="age" id="age" placeholder="填写年龄">
			    </div>
			  </div>
			<div class="form-group">
					    <label  class="col-sm-2 control-label">出生日期</label>
					    <div class="col-sm-10">
					      <input type="text" class="form-control"  maxlength="40" name="birthday" value="<fmt:formatDate value='<%=new Date() %>' pattern='yyyy-MM-dd'/>"  onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" id="birthday" placeholder="选择出生日期">
					    </div>
			</div>
			<div class="form-group">
					    <label  class="col-sm-2 control-label">部门</label>
					    <div class="col-sm-10">
					      <select  name="department" class="form-control" >
							<option>=选择部门=</option>
							<option value="1" selected="selected">研发部</option>
							<option value="2">销售部</option>
							<option value="3">市场部</option>
							</select>
					    </div>
			</div>
			<div class="form-group">
					    <label  class="col-sm-2 control-label">职位</label>
					    <div class="col-sm-10">
					     <select  name="posation" class="form-control">
					<option>=选择职位=</option>
					<option value="1" selected="selected">部门经理</option>
					<option value="2">经理助理</option>
					<option value="3">普通职员</option>
					</select>
					    </div>
			</div>
			<div class="form-group">
					    <label  class="col-sm-2 control-label">备注</label>
					    <div class="col-sm-10">
					     <textarea name="desc"  class="form-control" style="height:60px;">小木学堂-最专业的JFinal教程</textarea>
					    </div>
			</div>
			<button class="btn btn-success pull-right" onclick="submitForm()">提交Form</button>
 		</form>
  </fieldset>
  <fieldset>
  	<legend>AJAX异步提交</legend>
  	<button id="ajaxgetBtn" class="btn btn-primary">AJAX GET</button>
  	<button id="ajaxpostBtn" class="btn btn-success">AJAX POST</button>
  	<fieldset>
  	<legend>AJAX 结果</legend>
  	<div id="ajaxresult" style="width:400px;height:80px;border: 1px solid #CCC;margin-top: 5px;">
  	</div>
  	</fieldset>
  	<script type="text/javascript">
				$(function() {
					$("#ajaxgetBtn").click(function() {
						$("#ajaxresult").html("");
						$.ajax({
							type : "get",
							url : "/param/ajaxget?param=1",
							dataType : "json",
							success : function(result) {
								$("#ajaxresult").html(result.msg);
							}
						});
					});
					$("#ajaxpostBtn").click(function() {
						$("#ajaxresult").html("");
						$.ajax({
							type : "post",
							url : "/param/ajaxpost",
							data : {param1:1,param2:2},
							dataType : "json",
							success : function(result) {
								$("#ajaxresult").html(result.msg);
							}
						});
					});

				});
			</script>
  </fieldset>
  </div>
<jsp:include page="../qrcode.jsp"></jsp:include>
  </div>
  </div>
  <jsp:include page="../footer.jsp"></jsp:include>
